package io.simple.signals;



import simple.utils.concurrent.ConcurrentProperties;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: rehak
 * Date: 8/19/13
 * Time: 1:44 PM
 * To change this template use File | Settings | File Templates.
 */
public class Signal extends Exception {

    private final int statusCode;
    private final String msg;
    private ConcurrentProperties<String> responseHeaders = new ConcurrentProperties<>();

    public Signal(int statusCode, String msg, Map<String, List<String>> headers) {
        super(msg);
        this.msg = msg;
        this.statusCode = statusCode;
        for (Map.Entry<String, List<String>> e : headers.entrySet()) {
            for (String o : e.getValue()) {
                responseHeaders.add(e.getKey(), o);
            }
        }
    }

    public Signal(int statusCode, String msg, Map<String, List<String>> headers, Throwable rootCause) {
        super(msg, rootCause);
        this.msg = msg;
        this.statusCode = statusCode;
        for (Map.Entry<String, List<String>> e : headers.entrySet()) {
            for (String o : e.getValue()) {
                responseHeaders.add(e.getKey(), o);
            }
        }
    }

    public Signal(int statusCode, String msg) {
        super(msg);
        this.msg = msg;
        this.statusCode = statusCode;
    }

    public Signal(int statusCode, String msg, Throwable rootCause) {
        super(msg, rootCause);
        this.msg = msg;
        this.statusCode = statusCode;
    }

    public int getStatusCode() {
        return statusCode;
    }

    public String getMsg() {
        return msg;
    }

    public ConcurrentProperties<String> getResponseHeaders() {
        return responseHeaders;
    }
}
